/*
  Name: DeadProxyGetFileVersionInfo.cpp
  Copyright:
  Author: Carl Chatfield
  Date: 07/01/08 11:55
  Description: Get Version of Tibia client to ensure we have the correct client version
*/
#include "DeadProxyGetFileVersionInfo.h"
#include "windows.h"


int VersionGetter::GetVersion(const char * filename)
{
    DWORD lpdwHandle;
    DWORD dwHandle = 0;
    DWORD versionLength = GetFileVersionInfoSize((CHAR*)filename, &lpdwHandle);
    if(versionLength == 0)
    {
        return 0;
    }
    BYTE lpData[versionLength];
    if(GetFileVersionInfo((CHAR*)filename, dwHandle, versionLength, lpData) == 0)
    {
        return 0;
    }
    VS_FIXEDFILEINFO * fileinfo;
    //PUINT outputlength;
    VerQueryValue(lpData, "\\", (LPVOID *)&fileinfo, NULL);
    DWORD vRet = fileinfo->dwFileVersionMS;
    free (lpData);
    return vRet;
}
